#include <stdio.h>

int main(){
    double balance = 0;
    int chose;
    double deposit;
    double withdrawal;
    do{
        printf("============ATM============\n");
        printf("\t1.存款\n");
        printf("\t2.取款\n");
        printf("\t3.显示余额\n");
        printf("\t4.退出\n");
        printf("输入操作...\n");  
        scanf("%d", &chose);

        switch (chose)
        {
        case 1:
            printf("输入存款金额...\n");
            scanf("%lf", &deposit);
            balance += deposit;
            printf("存款成功\n");
            break;
        
        case 2:
            printf("输入取款金额...\n");
            scanf("%lf", &withdrawal);
            if(balance >= withdrawal){
                balance -= withdrawal;
                printf("取款成功\n");
                break;
            }
            else{
                printf("余额不足\n");
                break;
            }

        
        case 3:
            printf("当前余额：%.2lf\n", balance);
            break;

        case 4:
            break;

        default:
        printf("输入非法\n");
            break;
        }
    }
    while(chose!=4);

    return 0;


}